import request from '@/utils/request'

// 查询报修单列表
export function listRepairApplications(query) {
  return request({
    url: '/ldzl-sb/sb/repair/application/list',
    method: 'get',
    params: query
  })
}

// 查询报修单详情
export function getRepairApplication(id) {
  return request({
    url: '/ldzl-sb/sb/repair/application/' + id,
    method: 'get'
  })
}

// 新增报修单
export function addRepairApplication(data) {
  return request({
    url: '/ldzl-sb/sb/repair/application',
    method: 'post',
    data: data
  })
}

// 修改报修单
export function updateRepairApplication(data) {
  return request({
    url: '/ldzl-sb/sb/repair/application',
    method: 'put',
    data: data
  })
}

// 删除报修单
export function delRepairApplication(id) {
  return request({
    url: '/ldzl-sb/sb/repair/application/' + id,
    method: 'delete'
  })
}

// 接单处理
export function acceptRepairApplication(id) {
  return request({
    url: '/ldzl-sb/sb/repair/application/accept',
    method: 'post',
    params: { repair_id: id }
  })
}

// 取消报修单
export function cancelRepairApplication(id, reason) {
  return request({
    url: '/ldzl-sb/sb/repair/application/cancel',
    method: 'post',
    params: { repair_id: id, reason: reason }
  })
}

// 生成报修单编号
export function generateRepairCode() {
  return request({
    url: '/ldzl-sb/sb/repair/application/getNumber',
    method: 'get'
  })
}

// 查询维修单列表
export function listRepairOrder(query) {
  return request({
    url: '/ldzl-sb/repair/order/findAll/',
    method: 'get',
    params: query
  })
}

// 查询维修单详细
export function getRepairOrder(id) {
  return request({
    url: '/ldzl-sb/repair/order/findById/',
    method: 'get',
    params: { order_id: id }
  })
}

// 新增维修单
export function addRepairOrder(data) {
  return request({
    url: '/ldzl-sb/repair/order/save/',
    method: 'post',
    data: data
  })
}

// 修改维修单
export function updateRepairOrder(data) {
  return request({
    url: '/ldzl-sb/repair/order/update/',
    method: 'post',
    data: data
  })
}

// 删除维修单
export function delRepairOrder(id) {
  return request({
    url: '/ldzl-sb/repair/order/delete/',
    method: 'get',
    params: { order_id: id }
  })
}

// 完成维修
export function completeRepair(data) {
  return request({
    url: '/ldzl-sb/repair/order/complete/',
    method: 'post',
    data: data
  })
}

// 取消维修
export function cancelRepair(id, reason) {
  return request({
    url: '/ldzl-sb/repair/order/cancel/',
    method: 'get',
    params: { order_id: id, cancel_reason: reason }
  })
} 